Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

151
Views
how to "destring" an object in an array

i have an array which looks like this:

[ 
"[-33.85812364015231, 151.19984484776273]", 
"[-33.85812364015231, 151.19984484776273]", 
"[-33.87137985320215, 151.19263084032974]"
]

how do i get the objects out of their strings. Parsing them into floats removed the second value in the object. Trying to replace( ' " ', " ") the speech marks doesn't work.

thanks

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You have an array of JSON strings.

To get an array of arrays of numbers, use

const parsedArr = arr.map(JSON.parse);

and then parsedArray[someNum] will give you a coordinate array of numbers, like [-33.85812364015231, 151.19984484776273].

about 4 years ago · Juan Pablo Isaza Report

0

this way :
without unnecessarily recreating a new array (as does the array.map() method )

const myArray = 
  [ "[-33.85812364015231, 151.19984484776273]"
  , "[-33.85812364015231, 151.19984484776273]" 
  , "[-33.87137985320215, 151.19263084032974]"
  ]
  
myArray.forEach((row,i,Arr) =>  Arr[i] = JSON.parse(row) )

console.log( myArray )
  

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!